Add a test for stable metadata across workspaces
authorTyler Hall <tylerwhall@gmail.com>
Sun, 29 Jan 2017 22:55:47 +0000 (17:55 -0500)
committerTyler Hall <tyler.hall@lexmark.com>
Sun, 25 Jun 2017 22:06:12 +0000 (18:06 -0400)
tests/build.rs

index f2081c61fa3edb68d8d85f7eaf0800d7c129abf4..f096b8fbd1e883b90dfc8f32de1ffec1565d2954 100644 (file)
@@ -1,4 +1,5 @@
 extern crate cargo;
+#[macro_use]
 extern crate cargotest;
 extern crate hamcrest;
 extern crate tempdir;
@@ -3271,3 +3272,32 @@ fn no_bin_in_src_with_lib() {
                 execs().with_status(101)
                        .with_stderr_contains(r#"[ERROR] couldn't read "[..]main.rs"[..]"#));
 }
+
+#[test]
+fn same_metadata_different_directory() {
+    // A top-level crate built in two different workspaces should have the
+    // same metadata hash.
+    let p = project("foo1")
+        .file("Cargo.toml", &basic_bin_manifest("foo"))
+        .file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
+    let output = t!(String::from_utf8(
+        t!(p.cargo_process("build").arg("-v").exec_with_output())
+            .stderr,
+    ));
+    let metadata = output
+        .split_whitespace()
+        .filter(|arg| arg.starts_with("metadata="))
+        .next()
+        .unwrap();
+
+    let p = project("foo2")
+        .file("Cargo.toml", &basic_bin_manifest("foo"))
+        .file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
+
+    assert_that(
+        p.cargo_process("build").arg("-v"),
+        execs().with_status(0).with_stderr_contains(
+            format!("[..]{}[..]", metadata),
+        ),
+    );
+}